home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Sound / SndPlayDoubleBuffer / _headers / ReadResource.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-15  |  2.3 KB  |  82 lines  |  [TEXT/CWIE]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Header for routines demonstrating how to read resource files without
  5. **    using the Resource Manager.
  6. **
  7. **    by Mark Cookson, Apple Developer Technical Support
  8. **
  9. **    File:    ReadResource.h
  10. **
  11. **    Copyright ©1996 Apple Computer, Inc.
  12. **    All rights reserved.
  13. **
  14. **    You may incorporate this sample code into your applications without
  15. **    restriction, though the sample code has been provided "AS IS" and the
  16. **    responsibility for its operation is 100% yours.  However, what you are
  17. **    not permitted to do is to redistribute the source as "Apple Sample
  18. **    Code" after having made changes. If you're going to re-distribute the
  19. **    source, we require that you make it clear in the source that the code
  20. **    was descended from Apple Sample Code, but that you've made changes.
  21. */
  22.  
  23. #ifndef __READRESOURCE__
  24. #define __READRESOURCE__
  25.  
  26. #include <Errors.h>
  27. #include <Resources.h>
  28.  
  29. #ifndef __DEFINES__
  30. #include "Defines.h"
  31. #endif
  32.  
  33. struct ResourceHeader {
  34.     long            resDataOffset;
  35.     long            resMapOffset;
  36.     long            resDataLength;
  37.     long            resMapLength;
  38. };
  39. typedef struct ResourceHeader ResourceHeader;
  40.  
  41. struct ResourceMap {
  42.     unsigned char    reserved1[16];//for copy of resource header
  43.     long            reserved2;//for handle to next resource map
  44.     short            reserved3;//for file reference number
  45.     short            resFileAttrs;
  46.     unsigned short    typesListOffset;
  47.     unsigned short    namesListOffset;
  48.     unsigned short    numTypesInMap;
  49. };
  50. typedef struct ResourceMap ResourceMap;
  51.  
  52. struct ResourceTypeListEntry {
  53.     OSType            resType;
  54.     unsigned short    numEntries;
  55.     unsigned short    referenceOffset;
  56. };
  57. typedef struct ResourceTypeListEntry ResourceTypeListEntry;
  58.  
  59. struct ResReference {
  60.     short            ID;
  61.     unsigned short    nameOffset;
  62.     long            dataOffset;//high byte is actually resource attributes, low three bytes are offset to beginning of data
  63.     long            reserved;//for handle to resource
  64. };
  65. typedef struct ResReference ResReference;
  66.  
  67.         OSErr    MyGetFirstResource        (short refNum,
  68.                                         OSType targetType,
  69.                                         short *targetID);
  70.  
  71.         OSErr    MyGetResourcePosition    (short refNum,
  72.                                         OSType targetType,
  73.                                         short targetID,
  74.                                         long *firstByte);
  75.         
  76.         OSErr    MyGetTypesPosition        (short refNum,
  77.                                         OSType theType,
  78.                                         short *numResources,
  79.                                         long *dataOffset,
  80.                                         long *firstByteOfTypeList);
  81.  
  82. #endif